package com.ruoyi.system.service.aid.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.aid.AidDonationMapper;
import com.ruoyi.system.domain.aid.AidDonation;
import com.ruoyi.system.service.aid.IAidDonationService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;

/**
 * 物资捐赠Service业务层处理
 */
@Service
public class AidDonationServiceImpl implements IAidDonationService {
    @Autowired
    private AidDonationMapper donationMapper;

    /**
     * 查询物资捐赠列表
     * 
     * @param donation 物资捐赠信息
     * @return 物资捐赠
     */
    @Override
    public List<AidDonation> selectAidDonationList(AidDonation donation) {
        return donationMapper.selectAidDonationList(donation);
    }

    /**
     * 查询物资捐赠详细
     * 
     * @param donationId 物资捐赠ID
     * @return 物资捐赠
     */
    @Override
    public AidDonation selectAidDonationById(Long donationId) {
        return donationMapper.selectAidDonationById(donationId);
    }

    /**
     * 新增物资捐赠
     * 
     * @param donation 物资捐赠信息
     * @return 结果
     */
    @Override
    public int insertAidDonation(AidDonation donation) {
        donation.setCreateTime(DateUtils.getNowDate());
        donation.setCreateBy(SecurityUtils.getUsername());
        return donationMapper.insertAidDonation(donation);
    }

    /**
     * 修改物资捐赠
     * 
     * @param donation 物资捐赠信息
     * @return 结果
     */
    @Override
    public int updateAidDonation(AidDonation donation) {
        donation.setUpdateTime(DateUtils.getNowDate());
        donation.setUpdateBy(SecurityUtils.getUsername());
        return donationMapper.updateAidDonation(donation);
    }

    /**
     * 批量删除物资捐赠
     * 
     * @param donationIds 需要删除的物资捐赠ID
     * @return 结果
     */
    @Override
    public int deleteAidDonationByIds(Long[] donationIds) {
        return donationMapper.deleteAidDonationByIds(donationIds);
    }

    /**
     * 删除物资捐赠信息
     * 
     * @param donationId 物资捐赠ID
     * @return 结果
     */
    @Override
    public int deleteAidDonationById(Long donationId) {
        return donationMapper.deleteAidDonationById(donationId);
    }

    @Override
    public List<AidDonation> selectAidDonationByDonorId(Long donorId) {
        return donationMapper.selectAidDonationByDonorId(donorId);
    }

    @Override
    public List<AidDonation> selectAidDonationByCategoryId(Long categoryId) {
        return donationMapper.selectAidDonationByCategoryId(categoryId);
    }

    @Override
    public List<AidDonation> selectAidDonationByStatus(String status) {
        return donationMapper.selectAidDonationByStatus(status);
    }
} 